
export const toast = (options) => {
  let body = {
    title: options.content || '--',
    icon: options && options.icon ? options.icon : 'none',
    duration: options && options.duration ? options.duration : 3000,
  }
  wx.showToast(body)
}

export const loading = (title) => {
  wx.showLoading({ title: title || '加载中...', })
}

export const closeLoading = () => {
  wx.hideLoading()
}

export const alert = (options) => {
  return new Promise((resolve, reject) => {
    wx.showModal({
      showCancel: false,
      title: options.title || '提示',
      content: options.content || '--',
      success (res) {
        if (res.confirm) {
          resolve()
        } else if (res.cancel) {
          reject()
        }
      }
    })
  })
}

export const confirm = (options) => {
  return new Promise((resolve, reject) => {
    wx.showModal({
      title: options.title || '提示',
      content: options.content || '--',
      cancelText: options.cancelText || '取消',
      confirmText: options.confirmText || '确定',
      success (res) {
        if (res.confirm) {
          resolve()
        } else if (res.cancel) {
          reject()
        }
      }
    })
  })
}